package com.weilive.core.netty.http;

import java.io.File;
import java.util.HashMap;

import com.weilive.core.utils.FileUtils;

public class HttpFiles {

	private static final HashMap<String, String> file_contents = new HashMap<String, String>();
	private static final String root_path = "web/";
	
	public static void reloadData() {
		file_contents.clear();
	}
	
	public static String getFileContent(String file) throws Exception {
		String ret =  file_contents.get(file);
		if (ret == null) {
			System.out.println("===>" + root_path + file);
			String path = FileUtils.getResourcePath(root_path + file);
			System.out.println("===>" + path);
			if (path != null) {
				ret = FileUtils.readFileContent(new File(path));
				file_contents.put(file, ret);
			}
		}
		return ret;
	}
}
